﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using CentralOffice.PublicAffair.Data;
using CentralOffice.PublicAffair.BusinessActions;

using NoticeTable = CentralOffice.PublicAffair.Data.NoticeDataSet.NotificationsDataTable;
using NoticeRow = CentralOffice.PublicAffair.Data.NoticeDataSet.NotificationsRow;

namespace CentralOffice.WebClient.PublicAffairs
{
    public partial class NoticeView : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                string id = HttpContext.Current.Request.QueryString["id"];
                NoticeRow notice = CentralOffice.PublicAffair.BusinessActions.Notification.GetById(new Guid(id));
                if (notice != null)
                {
                    lblName.Text = notice.Name;

                    lblSignificant.Text = notice.Significant;

                    lblProfile.Text = notice[(notice.Table as NoticeTable).ProfileColumn.ColumnName] != System.DBNull.Value ? notice.Profile : "";
                    lblCreatedTime.Text = notice.CreatedTime.ToString();

                    lblNoticeContent.Text = Server.HtmlDecode(notice.ContentText);
                    if (notice[(notice.Table as NoticeTable).AttachmentsColumn.ColumnName] != System.DBNull.Value)
                    {
                        SiteUtil.GenernateDownloadHyperLink(hlAttachments, notice.Attachments);

                    }
                }
            }
        }
    }
}
